//
//  ArticlePushAnimate.m
//  SinaWebo
//
//  Created by 王方伟 on 2017/1/23.
//  Copyright © 2017年 亦心. All rights reserved.
//

#import "ArticlePushAnimate.h"
#import "TitlePresentationController.h"

@interface ArticlePushAnimate ()
@property (assign, nonatomic) BOOL isPresented;
@end

@implementation ArticlePushAnimate

- (UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source{
    TitlePresentationController *presnetVC = [[TitlePresentationController alloc] initWithPresentedViewController:presented presentingViewController:presenting];
    presnetVC.frame = [UIScreen mainScreen].bounds;
    return presnetVC;
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
    _isPresented = TRUE;
    return self;
}

- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
    _isPresented = FALSE;
    return self;
}

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext{
    return 0.3;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{
    UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
//    UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
   [transitionContext.containerView addSubview:fromVC.view];
}
@end
